Cache Class
A game only has one instance of a Cache and it is used to store all externally loaded assets such as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
Constructor
Item Index
Methods
Methods
-
key
Get a Texture by key.
Parameters:
-
keyStringAsset key of the RenderTexture you want.
Returns:
addAudio
-
obj
Add a new sound.
Parameters:
-
objObjectThe audio file object
-
keyStringAsset key for the audio.
-
urlStringURL of this audio file.
-
dataArrayBuffer | AudioThe loaded audio data
-
webAudioBooleanIs this a webAudio ArrayBuffer for a sound?
-
decodedBooleanIs the data decoded yet?
-
addBitmapFont
-
obj
Add a new Bitmap Font.
Parameters:
-
objObjectThe bitmap font file object
-
keyStringAsset key for the font texture.
-
urlStringURL of this font xml file.
-
dataObjectExtra font data.
-
formatNumberThe format of the bitmap font data
-
-
key
Get a Texture by key.
Parameters:
-
keyStringAsset key of the RenderTexture you want.
Returns:
addCanvas
-
obj
Add a new canvas.
Parameters:
-
objObjectThe spritesheet object
-
keyStringAsset key for this canvas.
-
canvasHTMLCanvasElementCanvas DOM element.
-
contextCanvasRenderingContext2DRender context of this canvas.
-
-
key
Get a Bitmap Font by key.
Parameters:
-
keyStringAsset key of the Bitmap Font you want.
Returns:
addImage
-
obj
Add a new image.
Parameters:
-
objObjectThe image file object
-
keyStringAsset key for the image.
-
urlStringURL of this image file.
-
imageImageThe image object that was loaded
-
addSpriteSheet
-
obj
Add a new sprite sheet.
Parameters:
-
objObjectThe spritesheet object
-
keyStringAsset key for the sprite sheet.
-
urlStringURL of this sprite sheet file.
-
imageImageThe image of the sprite sheet
-
frameWidthNumberWidth of the sprite sheet.
-
frameHeightNumberHeight of the sprite sheet.
-
frameMaxNumberHow many frames stored in the sprite sheet.
-
addText
-
obj
Add a new text data.
Parameters:
-
objObjectThe text file object
-
keyStringAsset key for the text data.
-
urlStringURL of this text data file.
-
dataObjectExtra text data.
-
addTextureAtlas
-
obj
Add a new texture atlas.
Parameters:
-
objObjectThe texture atlas file object
-
keyStringAsset key for the texture atlas.
-
urlStringURL of this texture atlas file.
-
formatNumberThe format of the atlas data ATLAS_FORMAT.JSON_ARRAY, ATLAS_FORMAT.JSON_HASH, or ATLAS_FORMAT.STARLING_XML
-
dataObjectThe texture atlas data exported from TexturePacker
-
imageImageThe texture image
-
addTilemap
-
obj
Add a new tilemap.
Parameters:
-
objObjectThe tilemap file object
-
keyStringAsset key for the tilemap
-
urlStringURL of the tilemap data file
-
dataObjectThe loaded tilemap data
-
formatNumberThe format of the tilemap data
-
[images]Arrayoptional Array of images used in the tilesets of this tilemap
-
destroy
()
Destroys this object, removing references so the GC can cleanup
getAudio
-
key
Get sound by key.
Parameters:
-
keyStringAsset key of the sound you want.
Returns:
getAudioData
-
key
Get sound data by key.
Parameters:
-
keyStringAsset key of the sound you want.
Returns:
getCanvas
-
key
Get canvas by key.
Parameters:
-
keyStringAsset key of the canvas you want.
Returns:
getImage
-
key
Get image data by key.
Parameters:
-
keyStringAsset key of the image you want.
Returns:
getText
-
key
Get text data by key.
Parameters:
-
keyStringAsset key of the text data you want.
Returns:
The text data you want.
getTilemap
-
key
Get tilemap data by key.
Parameters:
-
keyStringAsset key of the tilemap you want.
Returns:
The tilemap file data. The map data is in the data property, the images (for tileset) are in images
removeCanvas
-
key
Remove a canvas by key.
Parameters:
-
keyStringkey to remove
removeImage
-
key
Remove an image by key.
Parameters:
-
keyStringkey to remove
removeSound
-
key
Remove a sound by key.
Parameters:
-
keyStringkey to remove
removeText
-
key
Remove a text by key.
Parameters:
-
keyStringkey to remove
Properties
_canvases
Object
private
Canvas key-value container.
_images
Object
private
Image key-value container.
_sounds
Object
private
Sound key-value container.
_text
Object
private
Text key-value container.
_tilemaps
Object
private
Tilemap key-value container.